ResettableLazy
Ecng.Common
A lazy initialization wrapper that supports resetting.
Construtores
ResettableLazy
public ResettableLazy(Func<T> valueFactory)
resettableLazy = ResettableLazy(valueFactory)
Initializes a new instance of the ResettableLazy class.
- valueFactory
- The delegate that is invoked to produce the lazily initialized value when it is needed.
ResettableLazy
public ResettableLazy(Func<T> valueFactory, LazyThreadSafetyMode mode)
resettableLazy = ResettableLazy(valueFactory, mode)
Initializes a new instance of the ResettableLazy class.
- valueFactory
- The delegate that is invoked to produce the lazily initialized value when it is needed.
- mode
- The lazy thread-safety mode.
Propriedades
IsValueCreated
public bool IsValueCreated { get; }
value = resettableLazy.IsValueCreated
Gets a value that indicates whether a value has been created for this instance.
Value
public T Value { get; }
value = resettableLazy.Value
Gets the lazily initialized value of the current instance.
Métodos
op_Implicit(ResettableLazy{) : T
Implicitly converts to the underlying value.
Reset
public void Reset()
resettableLazy.Reset()
Resets the lazy initialization, allowing the value to be recreated on next access.
SetValue
public void SetValue(T value)
resettableLazy.SetValue(value)
Sets the value directly without calling the factory.
- value
- The value to set.
ToString
public override string ToString()
result = resettableLazy.ToString()
Returns a string that represents the current object.